<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>客户管理</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <style>
        body {
            background-color: #f5f8fa;
            font-family: 'Inter', sans-serif;
            padding: 20px;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            background-color: white;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
            padding: 25px;
        }
        h2 {
            color: #0f3460;
            margin-bottom: 20px;
            font-weight: 600;
        }
        .search-bar {
            display: flex;
            gap: 10px;
            margin-bottom: 20px;
        }
        .search-bar input {
            flex-grow: 1;
            padding: 8px 12px;
            border: 1px solid #ddd;
            border-radius: 6px;
        }
        .search-bar button {
            background-color: #0f3460;
            color: white;
            border: none;
            border-radius: 6px;
            padding: 8px 15px;
            cursor: pointer;
        }
        .search-bar button:hover {
            background-color: #1a508b;
        }
        .action-buttons {
            margin-bottom: 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .add-btn {
            background-color: #28a745;
            color: white;
            padding: 8px 15px;
            border-radius: 6px;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
        }
        .add-btn:hover {
            background-color: #218838;
            color: white;
            text-decoration: none;
        }
        .back-btn {
            color: #0f3460;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
        }
        .back-btn:hover {
            text-decoration: underline;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
        }
        th, td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }
        th {
            background-color: #f8f9fa;
            color: #0f3460;
            font-weight: 600;
        }
        tr:hover {
            background-color: #f5f5f5;
        }
        .action-link {
            margin-right: 10px;
            text-decoration: none;
            padding: 2px 5px;
            border-radius: 3px;
        }
        .edit-link {
            color: #007bff;
        }
        .edit-link:hover {
            background-color: #e8f4ff;
        }
        .delete-link {
            color: #dc3545;
        }
        .delete-link:hover {
            background-color: #ffebee;
        }
    </style>
</head>
<body>
    <div class="container">
        <h2>客户管理</h2>
<!-- <form method="get" action="{{ url_for('admin.list_customers') }}" class="search-bar">
    <input type="text" name="q" placeholder="搜索姓名或身份证号" value="{{ keyword or '' }}">
    <button type="submit">搜索</button>
</form> -->

<form method="get" action="{{ url_for('admin.search_customers') }}" class="search-bar">
  <input type="text" name="q" placeholder="输入客户姓名或身份证" value="{{ keyword or '' }}">
  <button type="submit">搜索</button>
</form>



        <div class="action-buttons">
            <a href="{{ url_for('admin.add_customer') }}" class="add-btn">
                <i class="fa fa-plus"></i> 添加客户
            </a>
            <a href="{{ url_for('admin.dashboard') }}" class="back-btn">
                <i class="fa fa-arrow-left"></i> 返回仪表盘
            </a>
        </div>

        <table>
            <thead>
                <tr>
                    <th>客户ID</th>
                    <th>姓名</th>
                    <th>身份证</th>
                    <th>电话</th>
                    <th>地址</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {% for customer in customers %}
                <tr>
                    <td>{{ customer.customerID }}</td>
                    <td>{{ customer.customerName }}</td>
                    <td>{{ customer.PID }}</td>
                    <td>{{ customer.telephone }}</td>
                    <td>{{ customer.address or '' }}</td>
                    <td>
                        <a href="{{ url_for('admin.edit_customer', customerID=customer.customerID) }}" class="action-link edit-link">
                            <i class="fa fa-pencil"></i> 编辑
                        </a>
                        <a href="{{ url_for('admin.delete_customer', customerID=customer.customerID) }}" onclick="return confirm('确认删除该客户？')" class="action-link delete-link">
                            <i class="fa fa-trash"></i> 删除
                        </a>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</body>
</html>